package com.shujia.json;

import com.alibaba.fastjson.JSON;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class Demo5ReadJson {

    public static void main(String[] args) throws Exception {

        BufferedReader bufferedReader = new BufferedReader(new FileReader("java/data/students.json"));


        ArrayList<Student> students = new ArrayList<>();
        String line;
        while ((line = bufferedReader.readLine()) != null) {

            //将json字符串转换成自定义类的对象
            Student student = JSON.parseObject(line, Student.class);
            students.add(student);

        }

        bufferedReader.close();

        System.out.println(students);

    }
}
